package com.zyuuo.warehouse.web;


import com.zyuuo.warehouse.ex.ServiceException;
import lombok.Data;

import java.io.Serializable;

@Data
public class Result implements Serializable {
    private Integer code;
    private String message;
    private Object data;


    public static Result success(){
        Result result=new Result();
        result.setCode(ServiceCode.OK.getValue());
        return result;
    }

    public static Result fail(ServiceException e) {
        return fail(e.getServiceCode(),e.getMessage());
    }

    public static Result fail(ServiceCode serviceCode,String message){
        Result result=new Result();
        result.setCode(serviceCode.getValue());
        result.setMessage(message);
        return result;
    }

}
